using System;
using System.Text;

namespace PlugNT.Cms.Model
{

    [Serializable]
    public class ArticleInfo
    {
        private int _id;
        private string _no;
        private string _title;
        private string _contents;
        private bool _commend;        
        private bool _stick;
        private bool _publish;        
        private int _channel_id;
        private string _channel_no_list;
        private DateTime _addtime;





        public int id
        {
            set { _id = value; }
            get { return _id; }
        }



        public string no
        {
            set { _no = value; }
            get { return _no; }
        }



        public string title
        {
            set { _title = value; }
            get { return _title; }
        }



        public int channel_id
        {
            set { _channel_id = value; }
            get { return _channel_id; }
        }



        public string channel_no_list
        {
            set { _channel_no_list = value; }
            get { return _channel_no_list; }
        }



        public string contents
        {
            set { _contents = value; }
            get { return _contents; }
        }



        public bool commend
        {
            set { _commend = value; }
            get { return _commend; }
        }



        public bool stick
        {
            set { _stick = value; }
            get { return _stick; }
        }



        public bool publish
        {
            set { _publish = value; }
            get { return _publish; }
        }



        public DateTime addtime
        {
            set { _addtime = value; }
            get { return _addtime; }
        }









        protected System.Collections.Generic.Dictionary<string,PlugNT.Cms.Custom.FieldModel> extfields = null;







        public bool SetExtField(string fieldName, string fieldType, string fieldValue)
        {
            bool flag = false;
            if (extfields == null)
            {
                extfields = new System.Collections.Generic.Dictionary<string, PlugNT.Cms.Custom.FieldModel>();
            }
            if (extfields.ContainsKey(fieldName))
            {
                flag = true;
                PlugNT.Cms.Custom.FieldModel field = new PlugNT.Cms.Custom.FieldModel();
                field.fieldName = fieldName;
                field.fieldType = fieldType;
                field.fieldValue = fieldValue;
                extfields[fieldName] = field;
            }
            else
            {
                flag = true;
                PlugNT.Cms.Custom.FieldModel field = new PlugNT.Cms.Custom.FieldModel();
                field.fieldName = fieldName;
                field.fieldType = fieldType;
                field.fieldValue = fieldValue;
                extfields.Add(fieldName, field);
            }
            return flag;
        }







        public bool SetExtField(PlugNT.Cms.Custom.FieldModel field)
        {
            bool flag = false;
            if (extfields == null)
            {
                extfields = new System.Collections.Generic.Dictionary<string, PlugNT.Cms.Custom.FieldModel>();
            }
            if (extfields.ContainsKey(field.fieldName))
            {
                flag = true;
                extfields[field.fieldName] = field;
            }
            else
            {
                flag = true;
                extfields.Add(field.fieldName, field);
            }
            return flag;
        }






        public PlugNT.Cms.Custom.FieldModel GetExtField(string fieldName)
        {
            PlugNT.Cms.Custom.FieldModel mValue = null;
            if (extfields != null && extfields.ContainsKey(fieldName))
            {
                mValue = extfields[fieldName];
            }
            return mValue;
        }





        public string[] GetExtFieldInsertSqlString()
        {
            string[] strArr = new string[2]{"",""};
            if (extfields != null)
            {
                StringBuilder sbFieldName = new StringBuilder();
                StringBuilder sbFieldValue = new StringBuilder();
                foreach (PlugNT.Cms.Custom.FieldModel info in extfields.Values)
                {
                    sbFieldName.Append("," + info.fieldName);
                    if (info.fieldType == PlugNT.Cms.Custom.FieldType.integerType)
                    {
                        sbFieldValue.Append("," + info.fieldValue);
                    }
                    else
                    {
                        sbFieldValue.Append(",'" + info.fieldValue + "'");
                    }
                }
                strArr[0] = sbFieldName.ToString();
                strArr[1] = sbFieldValue.ToString();
            }
            return strArr;
        }





        public string GetExtFieldUpdateSqlString()
        {
            string strValue = "";
            if (extfields != null)
            {
                StringBuilder sbFieldNameValue = new StringBuilder();
                foreach (PlugNT.Cms.Custom.FieldModel info in extfields.Values)
                {
                    if (info.fieldType == PlugNT.Cms.Custom.FieldType.integerType)
                    {
                        sbFieldNameValue.Append( "," + info.fieldName + "=" + info.fieldValue);
                    }
                    else
                    {
                        sbFieldNameValue.Append("," + info.fieldName + "='" + info.fieldValue+"'");
                    }
                }
                strValue = sbFieldNameValue.ToString();
            }
            return strValue;
        }




    }
}

